<?php require_once('init.php'); ?>
<div id="content">
<?php
if ( ! $node_id) {
    exit;
}
$node = new Node();
$node->setId($node_id);
$node->loadData();
$_SESSION['lastvisited'] = $node_id;
if ($node->getId()) {
$nodes = new Nodes();
?>
<?php require('templates/create_node_link.php'); ?>
        <div class="node">
            <div class="extradata">
                    <?php
                        foreach( $nodes->nodeChilds($nodes->getLinksFrom($node->getId())) as $link ) {
                            echo '<span class="to">';
                            $link->renderLink();
                            echo '</span> ';
                        }
                    ?>
                    <hr />
                    <form action="<?php echo DOMAIN; ?>/add_link.php" method="POST" id="add_link"> 
                        <input type="hidden" name="from_id" value="<?php echo $node->getId(); ?>" />
                        <input type="hidden" name="type_id" id="type_id" value="" />
                        <input type="hidden" name="to_id" id="to_id" value="" />
                        <small>Tipo de enlace (Categoría, Sinónimo, Imagen, etc.)</small>
                        <input type="text" name="type" id="type" class="autosuggest" />
                        <small>A donde enlazar</small>
                        <input type="text" name="to" id="to" class="autosuggest" />
                        <input type="submit" name="add" class="submit" value="Enlazar" />
                    </form>
            </div>
            <h3><?php echo $node->getName(); ?></h3>
            <div><?php echo $node->getContent(); ?></div>
            <div><?php $node->renderUrl(); ?></div>
        </div>
<?php
} else {
    echo '<h1>Node NOT found. PANIC!!!!</h1>';
}
?>
</div>
<?php
$options = array(
    'title' => $node->getName()
);
display($options);
